#include "main.h"
#include "stm32f0xx_hal.h"
#include "main.h"
#include "adc.h"
#include "tim.h"
#include "userGm5506.h"

volatile uint8_t gm5506Value;        //值范围从0-100 ，数值越大光照越强



void user_gm5506GetData()
{	
	  uint32_t adcValue;
		HAL_ADC_Start(&hadc);
		HAL_ADC_PollForConversion(&hadc,0xffff);
		adcValue=HAL_ADC_GetValue(&hadc);
		HAL_ADC_Stop(&hadc);
		HAL_Delay(1000);
	  gm5506Value=adcValue*100/4095; 
	
//	  printf("-------------adc:%d-----------gm:%d------------\r\n",adcValue,gm5506Value);
}

/***********************以下的是共串口交互函数********************/

uint8_t user_guangdu()
{
	return gm5506Value;
}
